﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FixedWorkInput.aspx.cs" Inherits="Basic4Net.OAWeb.Module_Workload.FixedWorkInput" %>

<%@ Register Assembly="Controls" Namespace="Basic4Net.Controls" TagPrefix="webdiyer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <link type="text/css" rel="stylesheet" href="../App_Themes/ui-lightness/main.css" />
    <script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
    <script type="text/javascript" src="../Scripts/Common.js"></script>   
    <script>
        var re = /^[0-9]+.?[0-9]*$/; //验证正数
        var delArr = new Array();

        //关闭遮罩层
        function CloseMask(formId) {
            ClosePopForm(formId, true);
            hideMask();
        }

        //---------------------------------------------------------------------------------其他 



        //编辑状态
        function modi(obj) {

            if (obj.readOnly == true) {
                //   obj.parentElement.style.textAlign = 'center';
                obj.style.textAlign = 'left';
                obj.style.border = 'solid #a5a5a5 1px;';
                obj.readOnly = false;
                obj.select();
                updateActivate = 1;
            }
        }


        //非编辑状态
        function unModi(obj, align) {
            if (obj.readOnly == false) {
                obj.parentElement.style.textAlign = align;
                obj.style.textAlign = align;
                obj.style.border = 'solid #ffffff 1px;';
                obj.readOnly = true;
                updateActivate = 0;
            }
        }


        //选中行高亮
        function SetHightLight(obj) {
            if (obj != null)
                obj.style.backgroundColor = "#fffccf";

            var table = document.getElementById('table');
            for (var i = 0; i < table.rows.length; i++) {
                var row = table.rows[i];
                if (row != null && row.rowIndex != obj.rowIndex) {
                    row.style.backgroundColor = "#ffffff";
                }
            }
        }


        function FilterCount() {
            var value = event.srcElement.value;
            var table = document.getElementById('table');
            var rowIndex = event.srcElement.parentElement.parentElement.rowIndex;
            var row = table.rows[rowIndex];
            if (value == 1) {
                row.cells[2].all[0].style.display = "none";
                //    row.cells[3].all[0].style.display = "none"; 
            }
            else {
                row.cells[2].all[0].style.display = "block";
                //    row.cells[3].all[0].style.display  = "block"; 
            }
        }


        function optionSettingScore(obj) { 
            unModi(obj, 'right');
            var id = obj.parentElement.parentElement.getAttribute("itemid");
            var value = obj.value;
            var oldValue = obj.oldvalue;
            if (value == null || value.length <= 0 || Number(value) == Number(oldValue))
                return;
           
            if (value.search(/^(-|\+)?\d+(\.\d+)?$/) == -1) {
                
                if (value.length > 0 && value.charAt(value.length - 1) == ".") {
                    value = value.substr(0, value.length - 1);
                    if (value.search(/^(-|\+)?\d+(\.\d+)?$/) == -1) {
                        obj.setAttribute("value", obj.getAttribute("oldvalue"));
                        return;
                    }
                    else {
                        if (CheckCh(value)) {
                            obj.setAttribute("value", value);
                            obj.setAttribute("oldvalue", value);
                        }
                        else {
                            obj.setAttribute("oldvalue", value);
                        }
                    }
                }
                else {
                    if (value.length == 0 || (/\D/.test(value))) {
                        obj.setAttribute("value", obj.getAttribute("oldvalue"));
                        return;
                    }
                    else {
                        obj.setAttribute("value", value);
                        obj.setAttribute("oldvalue", value);
                    }
                }
            }
            else {
                obj.setAttribute("oldvalue", value);
            }

            var lessonId = obj.parentElement.parentElement.lessonid;
            if (lessonId != null && lessonId.length > 0 && lessonId > 0) {
                UpdateLessonNum(lessonId, value);
            }
            else { 
                AddLessonNum(value, id);
            } 
        }


        //添加课时信息
        function AddLessonNum(lessonNum, teacherId) {
            PageMethods.AddLessonNum(teacherId, lessonNum, function (succ) {
                if(succ > 0)
                    Bind();
            }, function (err) {
                showMassgeBox("提示", "添加失败", 1, null);
            });
        }


        //修改课时信息
        function UpdateLessonNum(lessonId, lessonNum) {
            if (lessonId == null || lessonId <= 0 || lessonNum ==null || lessonNum <= 0)
                return;
            PageMethods.UpdateLessonNum(lessonId, lessonNum, function (succ) {
                if (succ > 0) { 
                    Bind();
                }
            }, function (err) {
                showMassgeBox("提示", "添加失败", 1, null);
            });
        }

        function Bind() {
            var teachCode = document.getElementById('txtTeachCode').value;
            document.getElementById('TeachCode').value = teachCode;
            document.getElementById('btnItemBind').click();
        }

    </script>
</head>
<body onload="myload();">
     <form id="form1" runat="server">
   <div style="overflow-y: auto; overflow-x: none; height: 98%;">
            <div class="mainWarp">
                <div class="pageBody" style="height: 96%;">
                    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
                    </asp:ScriptManager>  
                        
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                        <h3><label id="lblTitle">以下是对<% =CurrentYear %>学年 <% =CurrentMonth %> 月份教工固定工作量录入</label></h3>
                        <ul class="butList">
                            <li>
                                <asp:DropDownList ID="dropList1"  OnSelectedIndexChanged="DrPostChanged" runat="server" AutoPostBack="True">
                                    
                                </asp:DropDownList> 
                            </li>
                             <li>
                                输入姓名或工号：<input id="txtTeachCode" type="text" /> 
                             </li>
                            <li>
                                <input type="button" value="查询" class="commonBut" id="btnAddItem" onclick="Bind();" />
                            </li> 
                        </ul>  
                        <div style="overflow-y: auto; overflow-x: none; height: 90%;">
                            <table id="table" class="useList" style="width: 80%;">
                                <tr > 
<%--                                    <th style="text-align: left; padding-left: 5px;">
                                        职称</th>--%>
                                    <th style="text-align: left; padding-left: 5px;">
                                        工号</th> 
                                    <th style="text-align: left; padding-left: 5px;">
                                        姓名</th>
                                    <th style="text-align: left; padding-left: 5px;">
                                        性别</th>
<%--                                   <th  style="text-align: left; padding-left: 5px;">
                                        出生日期</th>--%>
                                   <th style=" width:15%;">
                                       课时</th>
                                </tr>
                        <asp:Repeater ID="Repeater1" runat="server">    
                            <ItemTemplate> 
                                <tr itemid="<%# Eval("TeacherID")%>" lessonid="<%# Eval("LessonID") %>" onclick="SetHightLight(this);" > 
                                    <%--<td style="text-align: left; padding-left: 5px;"><%# Eval("PostName")%></td>--%>
                                    <td style="text-align: left; padding-left: 5px;"><%# Eval("TeachCode")%></td>
                                    <td style="text-align: left; padding-left: 5px;"><%# Eval("TeachName")%></td>
                                    <td style="text-align: left; padding-left: 5px;"><%# Eval("Sexy")%></td>
                                    <%--<td style="text-align: left; padding-left: 5px;"><%# Eval("BirthDay")%></td>--%>
                                    <td>
                                    <input  onpaste="return false;"
                                    ondragenter="return false" maxlength="20" class="txtStyle" style="text-align: right;
                                    border-left: 0px; width: 95%; border-top: 0px; border-right: 0px; border-bottom: 0px;
                                    font-weight:inherit;color:#006f9f;
                                    font-style:inherit;
                                    font-size:12px; 
                                    font-family:'SimSun', Arial, Helvetica, sans-serif;"
                                    id="td<%# Eval("Lesson")%>" value="<%# Eval("Lesson")%>" oldvalue="<%# Eval("Lesson")%>"
                                    onfocusout="optionSettingScore(this)" onclick="modi(this)" readonly /> </td>  
                               </tr> 
                            </ItemTemplate>
                            </asp:Repeater> 
                        </table> 
                        </div>  
                            <div style=" text-align:left; padding-top:8px;">
                            <webdiyer:BNPager ID="aspNetPager" runat="server" PageSize="15" Width=680
                                 OnPageChanged="AspNetPagerPageChanged"   ShowPageIndex="true">
                            </webdiyer:BNPager>
                         </div>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnItemBind" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="aspNetPager" EventName="PageChanged" />
                </Triggers>
            </asp:UpdatePanel>

            <%--服务器端控件层--%>
            <div style="display:none;">
                <asp:Button runat="server" ID="btnItemBind" onclick="btnItemBind_Click"   />
                <asp:TextBox runat="server" ID="TeachName" />
                <asp:TextBox runat="server" ID="TeachCode" /> 
            </div>
                  
                     
                

            </div>
         </div>
        </div>
    </form>
</body>
</html>
<script type="text/javascript">
    function myload() {
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(EndRequestHandler);
    }
    function EndRequestHandler() {
        $("input[type='submit']").addClass("commonBut");
    }

    $("input[type='submit']").addClass("commonBut");
</script>